<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Demands;
use App\Models\Users;
use App\Models\rewardOrder;
use App\Models\OrderDetail;
use App\Models\BalanceLogs;
use App\Models\CashOuts;

class IndexController extends Controller {

    public function index(){
    	//计算任务总数
    	$rewardcounts = Demands::where("status",'<>',-1)->count();
    	
    	$hascounts = Demands::where("status",'<>',-1)->sum("ownnumber");
    	$usercounts = Users::where("status",'<>',-1)->count();
    	$map=[
    			"type"=>3,
    			"pay_state"=>2
    	];
    	$allmoneys = BalanceLogs::where($map)->sum("money");
    	
    	//用户总余额
    	$usersmoney = Users::where("status",'<>',-1)->sum('balance');
    	//已经体现金额
    	$hastxmoney = Users::where("status",'<>',-1)->sum('amount');
    	//正在申请提现
    	$cash_outs = CashOuts::where('status',1)->sum('amount');
        return view('admin.index.index',compact('rewardcounts','hascounts','usercounts','allmoneys','usersmoney','hastxmoney','cash_outs'));
    }

}
